/**
 * 
 */

/**
 * @author Enzo
 *
 */


import javax.swing.*;

public class MainFrameGUI {

	//Class Variables
	static JFrame mainFrame; //this is static in order for error messages to popup
	static final boolean VERBOSE = true;
	static DebugFrame errorFrame;
	
	
	
	/**
	 * @param args
	 */
	//Constructors
	public MainFrameGUI() {
		//Read in the stored data file 
		//loadDataFile();
		
		//Initialize the GUI interface 
		//Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
            	initialize();
            }
        });
		
	}
	
	
	private void initialize(){		
		//Create the mainFrame for the GUI
		//This mainFrame is never destroyed unless closed by the user
		//which terminates the program
		mainFrame = new JFrame("Enzo's To Do Manager System");
		mainFrame.setSize(400, 500);
		
		//Create the GUI components
		buildGUI();
		
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//mainFrame.pack();
		
		mainFrame.validate();
		mainFrame.setVisible(true);
		displayDebug("Main Frame validating and setting to visible");
		
	}
	
	/**
	 * @author Enzo
	 * Builds the GUI from scratch
	 */
	private void buildGUI(){
		//Create the center text field
		JTextField mainTitleTextField = new JTextField();
		mainTitleTextField.setText("To-Do List Program");

		
		/*
		 * Create components here
		 */
		ToDoListGUIComponent toDoList = new ToDoListGUIComponent();
		
		
		/*
		 * After finishing building the components,
		 * add it all to the mainFrame
		 */
		toDoList.paintOnFrame(mainFrame);		
	}
	
	
	
	
	
	
	
	
	//------------------------------------------------------------
	//Error and debug methods
	static void createGUIPopUpError(String errorString){
		System.out.println("ERROR: " +errorString);
		JOptionPane.showMessageDialog(mainFrame, errorString);
	}
	static void displayDebug(final String informationString){
		if(VERBOSE){

			errorFrame = new DebugFrame();
			javax.swing.SwingUtilities.invokeLater(new Runnable() {
	            public void run() {
	    			errorFrame.displayMessage(informationString);
	            }
	        });
		}
	}
	
	
	
	
	
	
	


}
